require "import" import "android.content.Intent" import "android.net.Uri" import "android.provider.Settings" import "android.widget.Toast" import "java.io.File" if usecontextualgesture usecontextualgesture=false this.play"gesture_end" this.speak "Keluar Dari Menu Gerakan Kontekstual" elseif not usecontextualgesture local listmenuoptions={"Volume","Tindakan geser","Kontrol pemutaran media","Tema Suara","Ekstensi","Waktu Tunggu Tampilan Layar"} function adjustindex(a,b) if type(b)=="table" local maxposition=#b if maxposition==0 return maxposition elseif a>maxposition return 1 elseif a<=0 return maxposition else return a end elseif type(b)=="number" if a>b return 1 elseif a<=0 return b else return a end else return a end end function handleMenuSelection(x) local selectedoption=listmenuoptions[menuoptionposition] local audiomanager=this.getSystemService(this.AUDIO_SERVICE) local function requestwritesettingspermission() local intent=Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS) intent.setData(Uri.parse("package:"..this.getPackageName())) this.startActivity(intent) this.beep() this.speak"Harap izinkan ubah pengaturan sistem supaya bisa berfungsi untuk mengubah pengaturan ini!" end local function getlistfunctions(a,b) local f=File(this.getLuaExtPath(a)).listFiles() local t={} if f~=nil and #f>0 for i=0,#f-1 if b=="Folder" and f[i].isDirectory() table.insert(t,f[i].getName()) elseif b=="File" and f[i].isFile() table.insert(t,f[i].getName()) elseif not b table.insert(t,f[i].getName()) end end table.sort(t) return t else return {} end end local function selectfunction(a,b,c,d) local a=adjustindex(a,b) if a>0 if c=="Volume" and d audiomanager.adjustStreamVolume(b[a].value,d,audiomanager.FLAG_SHOW_UI) if d==audiomanager.ADJUST_RAISE this.play"raise_volume" elseif d==audiomanager.ADJUST_LOWER this.play"lower_volume" end this.speak(c.." "..b[a].label.." "..audiomanager.getStreamVolume(b[a].value)) elseif c=="Volume" this.playSoundScroll() this.speak(c.." "..b[a].label.." "..audiomanager.getStreamVolume(b[a].value)) elseif c=="Mode Pengulangan" this.playSoundScroll() this.speak(b[a].label) elseif c=="Waktu Tunggu Tampilan Layar" if Settings.System.canWrite(this) Settings.System.putInt(this.getContentResolver(),Settings.System.SCREEN_OFF_TIMEOUT,b[a].value) this.playSoundScroll() this.speak(c.."\n"..b[a].label) elseif not Settings.System.canWrite(this) requestwritesettingspermission() end elseif c=="Tema Suara" and d==true this.loadSoundPackage(b[a]) this.playSoundScroll() this.speak(a.."\n"..b[a]) elseif c=="Ekstensi" and d==true this.plugin(b[a],node) elseif c=="Ekstensi" this.playSoundScroll() this.speak(a.."\n"..b[a]) end return a else this.beep() this.speak("Tidak ada "..c) return end end if not extensionposition extensionposition=1 end if not soundpackageposition soundpackageposition=1 end if not timeintervalposition timeintervalposition=1 end if not volumeposition volumeposition=3 end local listtimeintervals={{label="15 detik",value=15000},{label="30 detik",value=30000},{label="1 menit",value=60000},{label="2 menit",value=120000},{label="3 menit",value=180000},{label="4 menit",value=240000},{label="5 menit",value=300000},{label="10 menit",value=600000},{label="15 menit",value=900000},{label="20 menit",value=1200000},{label="25 menit",value=1500000},{label="30 menit",value=1800000}} local listvolume={{label="Aksesibilitas",value=audiomanager.STREAM_ACCESSIBILITY},{label="Alarm",value=audiomanager.STREAM_ALARM},{label="Media",value=audiomanager.STREAM_MUSIC},{label="Nada dering",value=audiomanager.STREAM_RING},{label="Notifikasi",value=audiomanager.STREAM_NOTIFICATION},{label="Panggilan",value=audiomanager.STREAM_VOICE_CALL},{label="Sistem",value=audiomanager.STREAM_SYSTEM}} if selectedoption=="Kontrol pemutaran media" and x==1 this.execute("Media sebelumnya") elseif selectedoption=="Kontrol pemutaran media" and x==2 this.execute("Media berikutnya") elseif selectedoption=="Kontrol pemutaran media" and x==3 this.execute("Mundur cepat") elseif selectedoption=="Kontrol pemutaran media" and x==4 this.execute("Maju cepat") elseif selectedoption=="Kontrol pemutaran media" and x==5 this.execute("Putar jeda") elseif selectedoption=="Kontrol pemutaran media" and x==6 this.execute("Putar jeda") elseif selectedoption=="Tindakan geser" and x==1 this.execute("geser ke atas halaman") elseif selectedoption=="Tindakan geser" and x==2 this.execute("geser ke bawah halaman") elseif selectedoption=="Tindakan geser" and x==3 this.execute("Geser ke kanan halaman") elseif selectedoption=="Tindakan geser" and x==4 this.execute("Geser ke kiri halaman") elseif selectedoption=="Volume" and x==1 volumeposition=selectfunction(volumeposition-1,listvolume,selectedoption) elseif selectedoption=="Volume" and x==2 volumeposition=selectfunction(volumeposition+1,listvolume,selectedoption) elseif selectedoption=="Volume" and x==3 selectfunction(volumeposition,listvolume,selectedoption,audiomanager.ADJUST_LOWER) elseif selectedoption=="Volume" and x==4 selectfunction(volumeposition,listvolume,selectedoption,audiomanager.ADJUST_RAISE) elseif selectedoption=="Volume" and x==5 selectfunction(volumeposition,listvolume,selectedoption,audiomanager.ADJUST_TOGGLE_MUTE) elseif selectedoption=="Volume" and x==6 selectfunction(volumeposition,listvolume,selectedoption,audiomanager.ADJUST_TOGGLE_MUTE) elseif selectedoption=="Waktu Tunggu Tampilan Layar" and x==1 timeintervalposition=selectfunction(timeintervalposition-1,listtimeintervals,selectedoption) elseif selectedoption=="Waktu Tunggu Tampilan Layar" and x==2 timeintervalposition=selectfunction(timeintervalposition+1,listtimeintervals,selectedoption) elseif selectedoption=="Waktu Tunggu Tampilan Layar" and x==3 timeintervalposition=selectfunction(timeintervalposition-1,listtimeintervals,selectedoption) elseif selectedoption=="Waktu Tunggu Tampilan Layar" and x==4 timeintervalposition=selectfunction(timeintervalposition+1,listtimeintervals,selectedoption) elseif selectedoption=="Waktu Tunggu Tampilan Layar" and x==5 timeintervalposition=selectfunction(timeintervalposition-1,listtimeintervals,selectedoption) elseif selectedoption=="Waktu Tunggu Tampilan Layar" and x==6 timeintervalposition=selectfunction(timeintervalposition+1,listtimeintervals,selectedoption) elseif selectedoption=="Ekstensi" and x==1 extensionposition=selectfunction(extensionposition-10,getlistfunctions("Plugin","Folder"),selectedoption) elseif selectedoption=="Ekstensi" and x==2 extensionposition=selectfunction(extensionposition+10,getlistfunctions("Plugin","Folder"),selectedoption) elseif selectedoption=="Ekstensi" and x==3 extensionposition=selectfunction(extensionposition-1,getlistfunctions("Plugin","Folder"),selectedoption) elseif selectedoption=="Ekstensi" and x==4 extensionposition=selectfunction(extensionposition+1,getlistfunctions("Plugin","Folder"),selectedoption) elseif selectedoption=="Ekstensi" and x==5 selectfunction(extensionposition,getlistfunctions("Plugin","Folder"),selectedoption,true) elseif selectedoption=="Ekstensi" and x==6 selectfunction(extensionposition,getlistfunctions("Plugin","Folder"),selectedoption,true) elseif selectedoption=="Tema Suara" and x==1 soundpackageposition=selectfunction(soundpackageposition-10,getlistfunctions("Suara","Folder"),selectedoption,true) elseif selectedoption=="Tema Suara" and x==2 soundpackageposition=selectfunction(soundpackageposition+10,getlistfunctions("Suara","Folder"),selectedoption,true) elseif selectedoption=="Tema Suara" and x==3 soundpackageposition=selectfunction(soundpackageposition-1,getlistfunctions("Suara","Folder"),selectedoption,true) elseif selectedoption=="Tema Suara" and x==4 soundpackageposition=selectfunction(soundpackageposition+1,getlistfunctions("Suara","Folder"),selectedoption,true) elseif selectedoption=="Tema Suara" and x==5 this.playSoundTick() elseif selectedoption=="Tema Suara" and x==6 this.playSoundTick() elseif selectedoption this.beep() this.speak("Tidak ada "..selectedoption) end end if not menuoptionposition menuoptionposition=1 end function selectmenuoption(a) if a=="+" menuoptionposition=adjustindex(menuoptionposition+1,listmenuoptions) elseif a=="-" menuoptionposition=adjustindex(menuoptionposition-1,listmenuoptions) end this.playSoundScroll() this.speak(listmenuoptions[menuoptionposition]) end usecontextualgesture=true this.play"gesture_start" this.speak("Memasuki Menu Gerakan Kontekstual".." : "..listmenuoptions[menuoptionposition]) end return true